<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>煤炭管理系统</title>
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/lib/layui/css/layui-theme-custom.css">
    <link rel="stylesheet" href="/static/css/member.css">
    <style>
        tr strong{
            color:#c0392b;
        }
    </style>
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <#include "/base/main-header.ftl">

    <#include "/base/main-left.ftl">
    <div class="layui-body">

        <#include "./template/Purchasing-info.ftl">
        <#include "./template/coal-quality.ftl">

        <div class="table-box">
            <div class="site-title">
                <fieldset>
                    <legend>
                        <a class="site-title-text">单据审批记录</a>
                    </legend>
                </fieldset>
            </div>
            <table class="layui-hide"  id="audit-tb"  >
            </table>
            <form class="layui-form"   id="audit-form">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="    width: 100px;">审批意见：
                    </label>
                    <input type="hidden" name="purchId" value="${p.purchApplyId!""}">
                    <div class="layui-input-block">
                        <textarea name="remark" required    placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>
                <div class="layui-form-item" style="display: flex; justify-content: center;margin: 20px;">
                    <button lay-filter="ok"  lay-submit="" class="layui-btn" id="audit-ok">审核通过</button>
                    <button lay-filter="reject" lay-submit=""  class="layui-btn layui-btn-danger" id="audit-reject">驳回</button>
                    <button class="layui-btn  layui-btn-primary" onclick="window.history.go(-1)">返回</button>
                </div>
            </form>
        </div>


    </div>
    <#include "/base/main-footer.ftl">
</div>

<script src="/static/lib/layui/layui.js"></script>
<script>
    layui.use(['layer', 'form', 'element', 'jquery','table'], function () {
        var layer = layui.layer, form = layui.form, $ = layui.$,table=layui.table;
        table.render({
            elem: '#audit-tb',
            url:'/purchAudit/list?purchId=${p.purchApplyId!""}',
            cols: [[
                {field:'id',width:300, title: '序号'}
                ,{field:'operName', width:150, title: '操作人员'}
                ,{field:'operDept', width:150, title: '单位'}
                ,{field:'operAction', width:80, title: '操作'}
                ,{field:'remark' , title: '审批意见'}
                ,{field:'operTime',   title: '操作时间'}
            ]]
            ,parseData: function(res){
                return {
                    "code": res.code,
                    "msg": res.msg,
                    "data": res.data
                };
            }
        });
        let loading = false
        form.on('submit(ok)', function (data) {
            if(loading){
                return false
            }
            loading = true
            $.ajax({
                type: "POST",
                url: "/pr/ok",
                data: data.field,
                success: function (data) {
                    if (data.isSuccess){

                        layer.msg("操作成功")
                        setTimeout(function () {
                            loading = false
                            window.location = "/auditPR"
                        },2000)
                    } else {
                        loading = false
                        layer.msg(data.msg)
                    }
                }
            });
            return false;
        });
        form.on('submit(reject)', function (data) {
            if(loading){
                return false
            }
            loading = true
            $.ajax({
                type: "POST",
                url: "/pr/reject",
                data: data.field,
                success: function (data) {
                    if (data.isSuccess){
                        layer.msg("操作成功")
                        setTimeout(function () {
                            loading = false
                            window.location = "/auditPR"
                        },2000)
                    } else {
                        loading = false
                        layer.msg(data.msg)
                    }
                }
            });
            return false;
        });
    });
</script>
</body>

</html>